using System;

class WarenkorbItem
{
    private Artikel item;

    /**
     * Der sich im Warenkorb befindende Artikel.
     */
    public Artikel Item
    {
        get => item;
    }

    private int anzahl;

    /**
     * Die Anzahl, wie oft der Artikel im Warenkorb liegt. Anzahl muss größer 0 sein.
     */
    public int Anzahl
    {
        get => anzahl;
        set
        {
            if (value > 0)
                anzahl = value;
        }
    }


    /**
     * Gibt den Gesamtpreis des Artikels zurück. Berechnet durch Verkaufspreis * Anzahl.
     */
    public double ItemPreis
    {
        get => item.Verkaufspreis * anzahl;
    }

    /**
     * Gibt einen String mit Informationen über den Artikel im Warenkorb zurück.
     * @return Einen String aus Id, Bezeichnung, Verkaufspreis, Anzahl und Gesamtpreis.
     */
    public string GetWarenkorbItemString()
    {
        return String.Format(item.GetArtikelString() + $" - Anzahl: {anzahl} - Gesamtpreis: {ItemPreis:C2}");
    }

    /**
     * Instanziiert ein neues Warenkorb-Item.
     * @param item Der Artikel im Warenkorb.
     * @param anzahl Die Anzahl, wie oft sich der Artikel im Warenkorb befindet.
     */
    public WarenkorbItem(Artikel item, int anzahl)
    {
        this.item = item;
        Anzahl = anzahl;
    }
}